package com.fastCms.manager.blueorder.controller;


import com.fastCms.business.blueorder.pojo.po.BlueMaterialPO;
import com.fastCms.business.blueorder.pojo.po.BlueMaterialSavePO;
import com.fastCms.business.blueorder.pojo.vo.BlueMaterialVO;
import com.fastCms.business.blueorder.service.BlueMaterialService;
import com.fastCms.business.frame.exception.BusinessException;
import com.fastCms.business.frame.pojo.PageParam;
import com.fastCms.business.frame.pojo.po.IdStrPO;
import com.fastCms.business.frame.response.ApiResponse;
import com.fastCms.business.frame.response.ResponseUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * blue-材料相关 前端控制器
 * </p>
 *
 * @author quan
 * @since 2024-10-17
 */
@RestController
@RequestMapping("/blueMaterial")
@Api(value = "BlueMaterialController", tags = "后台-材料管理")
public class BlueMaterialController {
    @Autowired
    private BlueMaterialService blueMaterialServiceImpl;

    @PostMapping("/showPage")
    @ApiOperation(value = "分页列表", notes = "分页")
    public ApiResponse<PageInfo<BlueMaterialVO>> showPage(@RequestBody PageParam<BlueMaterialPO> pageParam) {
        PageInfo<BlueMaterialVO> result = blueMaterialServiceImpl.showPage(pageParam);
        return ResponseUtil.success(result);
    }

    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "新建或更新", notes = "如果增加在下一层级,需要传pid")
    public ApiResponse<Boolean> saveOrUpdate(@RequestBody BlueMaterialSavePO param) throws BusinessException {
        Boolean result = blueMaterialServiceImpl.saveOrUpdateMaterial(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除", notes = "根据主键ID删除")
    public ApiResponse<Boolean> delete(@RequestBody IdStrPO param) throws BusinessException {
        ApiResponse<Boolean> result = blueMaterialServiceImpl.delete(param);
        return result;
    }
}

